#include <iostream>
#include <string>

int main() {
    std::string s;
    std::cout << "Введите скобочную последовательность ";
    std::cin >> s;
    std::string a = "";
    
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '[' || s[i] == ']' || s[i] == '(' || s[i] == ')' || s[i] == '{' || s[i] == '}' || s[i] == '<' || s[i] == '>') {
            a = a + s[i];
        }
    }
    
    while (s.find("()") != std::string::npos || s.find("{}") != std::string::npos || s.find("[]") != std::string::npos || s.find("<>") != std::string::npos) {
        if (s.find("()") != std::string::npos) {
            s.replace(s.find("()"), 2, "");
        }
        if (s.find("{}") != std::string::npos) {
            s.replace(s.find("{}"), 2, "");
        }